<template>
  <div>
    <ul class="news-list">
      <li v-for="(item, index) in related_list" :key="index">
        <!-- 置顶新闻 -->
        <div
          v-if="item.is_top == 1"
          @click="toDetail(item.news_id, 1)"
          class="is_top"
        >
          <h4>{{ item.title }}</h4>
          <div class="top-news-info">
            <div class="fl-left left-txt">
              <img src="~/assets/img/top.svg" alt="" />
              <span>{{ item.author }}</span>
              <span>{{ item.click_count }} {{ $t('Read') }}</span>
            </div>
            <div class="fl-right right-txt">
              <span v-if="isOpenCoin">{{
                $t('download_app_to_read_full_text_get_highest_$5')
              }}</span>
              <span v-if="!isOpenCoin">{{ $t('download_app_to_read') }}</span>
            </div>
          </div>
        </div>
        <!-- 图文 -->
        <div
          v-if="item.is_top != 1 && item.news_type == '1'"
          @click="toDetail(item.news_id, 1)"
        >
          <div class="pic-box">
            <div class="pic-content">
              <img v-lazy="item.thumbs[0]" alt="" class="img-cover" />
            </div>
          </div>
          <div class="info-box">
            <h4>{{ item.title }}</h4>
            <div class="news-info">
              <div class="fl-left left-txt">
                <span>{{ item.author }}</span>
                <span>{{ item.click_count }} {{ $t('Read') }}</span>
              </div>
              <div class="fl-right right-txt">
                <span v-if="isOpenCoin">{{
                  $t('download_app_to_read_full_text_get_highest_$5')
                }}</span>
                <span v-if="!isOpenCoin">{{ $t('download_app_to_read') }}</span>
              </div>
            </div>
          </div>
        </div>
        <!-- 图集 -->
        <div
          v-if="item.is_top != 1 && item.news_type == '2'"
          @click="toDetail(item.news_id, 2)"
        >
          <div class="pic-box">
            <div class="gl-bg"><img src="~/assets/img/gl_bg.png" alt="" /></div>
            <div class="pic-content">
              <img v-lazy="item.thumbs[0]" alt="" class="img-cover" />
            </div>
          </div>
          <div class="info-box">
            <h4>{{ item.title }}</h4>
            <div class="news-info">
              <div class="fl-left left-txt">
                <span>{{ item.author }}</span>
                <span>{{ item.click_count }} {{ $t('Read') }}</span>
              </div>
              <div class="fl-right right-txt">
                <span v-if="isOpenCoin">{{
                  $t('download_app_to_read_full_text_get_highest_$5')
                }}</span>
                <span v-if="!isOpenCoin">{{ $t('download_app_to_read') }}</span>
              </div>
            </div>
          </div>
        </div>
        <!-- 视频 -->
        <div
          v-if="item.is_top != 1 && item.news_type == '3'"
          @click="toDetail(item.news_id, 3)"
        >
          <div class="pic-box">
            <div class="pic-content">
              <img v-lazy="item.thumbs[0]" alt="" class="img-cover" />
            </div>
            <div class="player">
              <img src="~/assets/img/play.svg" alt="" />
            </div>
          </div>
          <div class="info-box">
            <h4>{{ item.title }}</h4>
            <div class="news-info">
              <div class="fl-left left-txt">
                <span>{{ item.author }}</span>
                <span>{{ item.play_count }} {{ $t('Play') }}</span>
              </div>
              <div class="fl-right right-txt">
                <span v-if="isOpenCoin">{{
                  $t('download_App_watch_video_get_highest_XXX')
                }}</span>
                <span v-if="!isOpenCoin">{{
                  $t('download_APP_to_get_more_fun')
                }}</span>
              </div>
            </div>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: {
    related_list: {
      default: []
    },
    isOpenCoin: {
      default: false
    }
  },
  methods: {
    /* 跳转详情 */
    toDetail: function(id, type) {
      this.$emit('toDetailFun', { id: id, type: type });
    }
  }
};
</script>

<style scoped lang="scss">
.news-list {
  li {
    padding: 16px;
    overflow: hidden;
    border-bottom: 1px solid #f7f7f9;
    &:hover {
      background: #f7f7f9;
      cursor: pointer;
    }
    /* 顶置新闻 */
    .is_top {
      h4 {
        font-size: 20px;
        color: #0c0c1c;
        font-weight: 400;
        margin: 0 0 10px 0;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        line-clamp: 1;
        -webkit-box-orient: vertical;
        line-height: 32px;
        height: 32px;
      }
      .top-news-info {
        overflow: hidden;
        color: #69768a;
        .left-txt {
          font-size: 12px;
          img {
            float: left;
            margin: 2px 4px 0 0;
            width: 16px;
          }
          span {
            margin: 0 8px 0 0;
          }
        }
        .right-txt {
          font-size: 12px;
          img {
            float: right;
          }
        }
      }
    }
    /* 图文,图集，视频，新闻框 */
    .pic-box {
      float: left;
      width: 115px;
      position: relative;
      .gl-bg {
        width: 115px;
        img {
          width: 100%;
        }
      }
      .player {
        width: 24px;
        height: 24px;
        position: absolute;
        left: 50%;
        top: 50%;
        z-index: 99;
        transform: translate(-50%, -50%);
        img {
          width: 100%;
          height: 100%;
        }
      }
      .pic-content {
        width: 100%;
        height: 92px;
        overflow: hidden;
        border-radius: 4px;
        position: relative;
        img {
          position: absolute;
          top: 50%;
          left: 50%;
          -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
        }
      }
      margin: 0 16px 0 0;
    }
    .info-box {
      float: right;
      width: 447px;
      h4 {
        font-size: 20px;
        color: #0c0c1c;
        font-weight: 700;
        line-height: 32px;
        height: 70px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
      }
      .news-info {
        overflow: hidden;
        color: rgba(12, 12, 28, 0.7);
        line-height: 24px;
        .left-txt {
          font-size: 12px;
          img {
            float: left;
            margin: 2px 4px 0 0;
          }
          span {
            margin: 0 16px 0 0;
          }
        }
        .right-txt {
          font-size: 12px;
          img {
            float: right;
            width: 16px;
            margin: 4px 0 0 0;
          }
        }
      }
    }
  }
}

.img-cover {
  width: 230px;
  height: 184px;
  object-fit: cover;
}

img[lazy=loading] {
  width: 230px;
  height: 184px;
  object-fit: cover;
}
</style>
